package com.example.demo.framework.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.zto.platform.cow.sdk.ApiClient;

public class ZTUtil {

	final static String company_id = "d95de10ab3194a19a044286db80ccb47";
	final static String company_key = "c804dd96d3fd";
	final static String url = "http://japi.zto.cn/";
	final static String test_url = "http://58.40.16.120:9001/";

	public static String ztBaseAreaGetAll() {
		String result = "";
		ApiClient client = new ApiClient(test_url + "baseAreaGetArea", company_id, company_key);
		Map<String, Object> param = new HashMap<>();
		param.put("company_id", company_id);
		param.put("msg_type", "GET_ALL");
		param.put("data", "{\"code\":0}");
		try {
			result = client.request(param);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}

	public static void main(String[] args) {
		List<String> list = new ArrayList<>();
		list.add("680000000000");
		ztTraceInterfaceNewTraces(list);
	}

	/**
	 * 获取快件轨迹
	 * 
	 * @param billCodes
	 * @return
	 */
	public static String ztTraceInterfaceNewTraces(List<String> billCodes) {
		String result = "";
		ApiClient client = new ApiClient(test_url + "traceInterfaceNewTraces", company_id, company_key);
		Map<String, Object> param = new HashMap<>();
		param.put("company_id", company_id);
		param.put("msg_type", "NEW_TRACES");
		JSONArray array = JSONArray.parseArray(JSON.toJSONString(billCodes));
		param.put("data", array.toJSONString());
		try {
			result = client.request(param);
			System.out.println(result);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}
